package Classes.Managers// ActionScript file
{
	import Classes.GameViews.ViewScenes.ViewScene;
	
	import flash.display.DisplayObjectContainer;

	/**
	 *游戏场景管理类 
	 * @author 葛增文
	 * 
	 */	
	public class M_GameScenes extends Manager
	{
		private static var _instance:M_GameScenes;/*静态引用*/
		private var _scnensAry:Array;/*场景数组*/
		public function M_GameScenes():void
		{
			_instance=this;
			this.init();
		}
		
		private function init():void
		{
			this._scnensAry=new Array;
		}
		
		public function joinScene(scene:ViewScene):void
		{
			this.scnensAry.push(scene);
		}
		
		public function openScene(scene:ViewScene):void
		{
			this.closeAll();
			this.showStage.addChild(scene);
		}
		
		public function closeAll():void
		{
			for each(var scene:ViewScene in this.scnensAry)
			{
				scene.close();
			}
		}
		
		/**
		 *释放 
		 * 
		 */		
		public function release():void
		{
			for each(var gameScene:ViewScene in this.scnensAry)
			{
				gameScene.release();
			}
			this._scnensAry=null;
		}

		/*getter & setter*/
		public static function get instance():M_GameScenes
		{
			return _instance;
		}

		public function get scnensAry():Array
		{
			return _scnensAry;
		}
		
		public function get showStage():DisplayObjectContainer
		{
			return this.main.showStage;
		}


	}
}